public class Day_23_1_微信红包 {
    public int getValue(int[] gifts, int n) {
        // write code here
        int temp = gifts[0];
        int count = 1;
        for(int i = 1; i < gifts.length; i++) {
            if(temp != gifts[i]) {
                count --;
                if(count == 0) {
                    temp = gifts[i];
                }
            }else {
                count ++;
            }
        }
        if(count > 0) {
            return temp;
        }else {
            return 0;
        }
    }
}
